from tkinter import *
import cv2
from PIL import Image, ImageTk#图像控件
import threading#多线程
from tkinter import filedialog
import numpy as np

#窗口
window = Tk()
window.title("这是一个窗口")
window.geometry("1200x550")
# window.overrideredirect(1)#删除标题栏
window.resizable(0,0) #禁止拉伸

#定义画布
canvas=Canvas(window,width=600,height=600)
canvas.place(x=0,y=0)

canvas1=Canvas(window,width=600,height=600)
canvas1.place(x=600,y=0)

def main():
    global img0
    img = cv2.imread("./inputs/1.jpg")
    cv2.imshow("photo",img)
    # img2 = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)#转换颜色从BGR到RGB
    print(img)
    img1 = Image.fromarray(np.uint8(img)).resize((600,500))#图像从array转换成Image对象，并修改尺寸
    img0 = ImageTk.PhotoImage(img1)
    canvas.create_image(0,0,anchor='nw',image=img0)

def print1():
    print(1)
    
#按钮
bt = Button(window,text='这是一个按钮',height=2,width=170,command=print1)
bt.place(x=0,y=500)


main()

window.mainloop()